package org.androidpn.http;

import java.util.HashMap;
import java.util.Map;

import org.androidpn.client.LogUtil;
import org.androidpn.model.CTalkList;
import org.androidpn.model.CUser;
import org.androidpn.model.CUserInfo;
import org.androidpn.utils.ConstanceUtil;

import android.text.TextUtils;
import android.util.Log;

import com.android.volley.AuthFailureError;
import com.android.volley.Request;
import com.android.volley.Response.ErrorListener;
import com.android.volley.Response.Listener;
import com.android.volley.toolbox.StringRequest;
import com.android.volley.toolbox.Volley;

/**
 * 所有的网络请求
 * 
 * @author wulianshu
 *
 */
public class HttpApi {

	/**
	 * 注册
	 * 
	 * @param user
	 *            用户信息
	 * @param listener
	 * @param errorListener
	 */
	public static void register(final CUser user, Listener<String> listener, ErrorListener errorListener) {
		StringBuilder sBuilder = new StringBuilder();
		sBuilder.append(ConstanceUtil.HOST_NAME);
		sBuilder.append("/cuser.do?func=register");
		HttpManager.getInstance().requestQueue.cancelAll(ConstanceUtil.REQUEST_REGISTER_TAG);
		StringRequest stringRequest = new StringRequest(Request.Method.POST, sBuilder.toString(), listener,
				errorListener) {
			@Override
			protected Map<String, String> getParams() throws AuthFailureError {
				// TODO Auto-generated method stub
				Map<String, String> paramsMap = new HashMap<String, String>();
				paramsMap.put("telephone", user.getTelephone());
				paramsMap.put("password", user.getPassword());
				paramsMap.put("device", user.getDeviceid());
				paramsMap.put("type", user.getType() + "");
				return paramsMap;
			}
		};
		stringRequest.setTag(ConstanceUtil.REQUEST_REGISTER_TAG);
		HttpManager.getInstance().requestQueue.add(stringRequest);
	}

	/**
	 * 登录
	 * 
	 * @param user
	 * @param listener
	 * @param errorListener
	 */
	public static void login(final CUser user, Listener<String> listener, ErrorListener errorListener) {
		StringBuilder sBuilder = new StringBuilder();
		sBuilder.append(ConstanceUtil.HOST_NAME);
		sBuilder.append("/cuser.do?func=login");
		HttpManager.getInstance().requestQueue.cancelAll(ConstanceUtil.REQUEST_LOGIN_TAG);
		StringRequest stringRequest = new StringRequest(Request.Method.POST, sBuilder.toString(), listener,
				errorListener) {
			@Override
			protected Map<String, String> getParams() throws AuthFailureError {
				// TODO Auto-generated method stub
				Map<String, String> paramsMap = new HashMap<String, String>();
				paramsMap.put("telephone", user.getTelephone());
				paramsMap.put("password", user.getPassword());
				return paramsMap;
			}
		};
		stringRequest.setTag(ConstanceUtil.REQUEST_LOGIN_TAG);
		HttpManager.getInstance().requestQueue.add(stringRequest);
	}

	/**
	 * 保存用户信息
	 * 
	 * @param userInfo
	 *            用户信息
	 * @param listener
	 *            成功的回调
	 * @param errorListener
	 *            失败的回调
	 */
	public static void saveUserinfo(final CUserInfo userInfo, Listener<String> listener, ErrorListener errorListener) {
		StringBuilder sBuilder = new StringBuilder();
		sBuilder.append(ConstanceUtil.HOST_NAME);
		sBuilder.append("/cuser.do?func=saveUserInfo");
		HttpManager.getInstance().requestQueue.cancelAll(ConstanceUtil.REQUEST_SAVEUSERINFO_TAG);
		StringRequest stringRequest = new StringRequest(Request.Method.POST, sBuilder.toString(), listener,
				errorListener) {
			@Override
			protected Map<String, String> getParams() throws AuthFailureError {
				// TODO Auto-generated method stub
				Map<String, String> paramsMap = new HashMap<String, String>();
				if (!TextUtils.isEmpty(userInfo.getTelephone())) {
					paramsMap.put("telephone", userInfo.getTelephone());
				}
				paramsMap.put("type", userInfo.getType() + "");
				paramsMap.put("name", userInfo.getName());
				paramsMap.put("age", userInfo.getAge() + "");
				paramsMap.put("sex", userInfo.getSex() + "");
				if (!TextUtils.isEmpty(userInfo.getTag())) {
					paramsMap.put("tag", userInfo.getTag());
				}
				if (!TextUtils.isEmpty(userInfo.getDescription())) {
					paramsMap.put("description", userInfo.getDescription());
				}
				if (!TextUtils.isEmpty(userInfo.getHospital())) {
					paramsMap.put("hospital", userInfo.getHospital());
				}
				if (!TextUtils.isEmpty(userInfo.getMajor())) {
					paramsMap.put("major", userInfo.getMajor());
				}
				return paramsMap;
			}
		};
		stringRequest.setTag(ConstanceUtil.REQUEST_SAVEUSERINFO_TAG);
		HttpManager.getInstance().requestQueue.add(stringRequest);
	}

	/**
	 * 获取短信验证码
	 * 
	 * @param telephone
	 *            注册的手机号码
	 * @param code
	 *            验证码
	 * @param listener
	 * @param errorListener
	 */
	public static void sendIndentifyCode(final String telephone, final String code, Listener<String> listener,
			ErrorListener errorListener) {
		StringBuilder sBuilder = new StringBuilder();
		sBuilder.append(ConstanceUtil.HOST_NAME);
		sBuilder.append("/cuser.do?func=sendIndentifyCode");
		HttpManager.getInstance().requestQueue.cancelAll(ConstanceUtil.REQUEST_SENDINDENTIFYCODE);
		StringRequest stringRequest = new StringRequest(Request.Method.POST, sBuilder.toString(), listener,
				errorListener) {
			@Override
			protected Map<String, String> getParams() throws AuthFailureError {
				// TODO Auto-generated method stub
				Map<String, String> paramsMap = new HashMap<String, String>();
				paramsMap.put("mobile", telephone);
				paramsMap.put("code", code);
				return paramsMap;
			}
		};
		stringRequest.setTag(ConstanceUtil.REQUEST_SENDINDENTIFYCODE);
		HttpManager.getInstance().requestQueue.add(stringRequest);
	}

	/**
	 * 标签用于推荐算法
	 * 
	 * @param telephone
	 * @param hotTag
	 * @param listener
	 * @param errorListener
	 */
	public static void setHotTag(final String telephone, final String hotTag, Listener<String> listener,
			ErrorListener errorListener) {
		StringBuilder sBuilder = new StringBuilder();
		sBuilder.append(ConstanceUtil.HOST_NAME);
		sBuilder.append("/cuser.do?func=setHotTag");
		HttpManager.getInstance().requestQueue.cancelAll(ConstanceUtil.REQUEST_SETHOTTAG);
		StringRequest stringRequest = new StringRequest(Request.Method.POST, sBuilder.toString(), listener,
				errorListener) {
			@Override
			protected Map<String, String> getParams() throws AuthFailureError {
				// TODO Auto-generated method stub
				Map<String, String> paramsMap = new HashMap<String, String>();
				paramsMap.put("telephone", telephone);
				paramsMap.put("tag", hotTag);
				return paramsMap;
			}
		};
		stringRequest.setTag(ConstanceUtil.REQUEST_SETHOTTAG);
		HttpManager.getInstance().requestQueue.add(stringRequest);
	}

	/**
	 * 添加用户
	 * 
	 * @param mytelephone
	 * @param frtelephone
	 * @param listener
	 * @param errorListener
	 */
	public static void addFriend(final String mytelephone, final String frtelephone, Listener<String> listener,
			ErrorListener errorListener) {
		StringBuilder sBuilder = new StringBuilder();
		sBuilder.append(ConstanceUtil.HOST_NAME);
		sBuilder.append("/cfriend.do?func=addFriend");
		HttpManager.getInstance().requestQueue.cancelAll(ConstanceUtil.REQUEST_ADDFRIEND);
		StringRequest stringRequest = new StringRequest(Request.Method.POST, sBuilder.toString(), listener,
				errorListener) {
			@Override
			protected Map<String, String> getParams() throws AuthFailureError {
				// TODO Auto-generated method stub
				Map<String, String> paramsMap = new HashMap<String, String>();
				paramsMap.put("mytelephone", mytelephone);
				paramsMap.put("frtelephone", frtelephone);
				return paramsMap;
			}
		};
		stringRequest.setTag(ConstanceUtil.REQUEST_ADDFRIEND);
		HttpManager.getInstance().requestQueue.add(stringRequest);
	}

	/**
	 * 删除用户
	 * 
	 * @param mytelephone
	 * @param frtelephone
	 * @param listener
	 * @param errorListener
	 */
	public static void deleteFriend(final String mytelephone, final String frtelephone, Listener<String> listener,
			ErrorListener errorListener) {
		StringBuilder sBuilder = new StringBuilder();
		sBuilder.append(ConstanceUtil.HOST_NAME);
		sBuilder.append("/cfriend.do?func=deleteFriend");
		HttpManager.getInstance().requestQueue.cancelAll(ConstanceUtil.REQUEST_DELETEFRIEND);
		StringRequest stringRequest = new StringRequest(Request.Method.POST, sBuilder.toString(), listener,
				errorListener) {
			@Override
			protected Map<String, String> getParams() throws AuthFailureError {
				// TODO Auto-generated method stub
				Map<String, String> paramsMap = new HashMap<String, String>();
				paramsMap.put("mytelephone", mytelephone);
				paramsMap.put("frtelephone", frtelephone);
				return paramsMap;
			}
		};
		stringRequest.setTag(ConstanceUtil.REQUEST_DELETEFRIEND);
		HttpManager.getInstance().requestQueue.add(stringRequest);
	}

	/**
	 * 注册用户
	 * 
	 * @param mytelephone
	 * @param frtelephone
	 * @param listener
	 * @param errorListener
	 */
	public static void registerDevice(final String telephone, final String device, Listener<String> listener,
			ErrorListener errorListener) {
		StringBuilder sBuilder = new StringBuilder();
		sBuilder.append(ConstanceUtil.HOST_NAME);
		sBuilder.append("/cuser.do?func=registerDevice");
		HttpManager.getInstance().requestQueue.cancelAll(ConstanceUtil.REQUEST_REGISTERDEVICE);
		StringRequest stringRequest = new StringRequest(Request.Method.POST, sBuilder.toString(), listener,
				errorListener) {
			@Override
			protected Map<String, String> getParams() throws AuthFailureError {
				// TODO Auto-generated method stub
				Map<String, String> paramsMap = new HashMap<String, String>();
				paramsMap.put("telephone", telephone);
				paramsMap.put("device", device);
				return paramsMap;
			}
		};
		stringRequest.setTag(ConstanceUtil.REQUEST_REGISTERDEVICE);
		HttpManager.getInstance().requestQueue.add(stringRequest);
	}

	/**
	 * 获取好友列表
	 * 
	 * @param telephone
	 * @param listener
	 * @param errorListener
	 */
	public static void getFriendList(final String telephone, Listener<String> listener, ErrorListener errorListener) {
		StringBuilder sBuilder = new StringBuilder();
		sBuilder.append(ConstanceUtil.HOST_NAME);
		sBuilder.append("/cfriend.do?func=getFriendList");
		HttpManager.getInstance().requestQueue.cancelAll(ConstanceUtil.REQUEST_GETFRIENDLIST);
		StringRequest stringRequest = new StringRequest(Request.Method.POST, sBuilder.toString(), listener,
				errorListener) {
			@Override
			protected Map<String, String> getParams() throws AuthFailureError {
				// TODO Auto-generated method stub
				Map<String, String> paramsMap = new HashMap<String, String>();
				paramsMap.put("telephone", telephone);
				return paramsMap;
			}
		};
		stringRequest.setTag(ConstanceUtil.REQUEST_GETFRIENDLIST);
		HttpManager.getInstance().requestQueue.add(stringRequest);
	}

	public static void getAllHotTagList(Listener<String> listener, ErrorListener errorListener) {
		StringBuilder sBuilder = new StringBuilder();
		sBuilder.append(ConstanceUtil.HOST_NAME);
		sBuilder.append("/cfriend.do?func=getAllHotTagList");
		HttpManager.getInstance().requestQueue.cancelAll(ConstanceUtil.REQUEST_GETALLHOTTAGLIST);
		StringRequest stringRequest = new StringRequest(Request.Method.POST, sBuilder.toString(), listener,
				errorListener);
		stringRequest.setTag(ConstanceUtil.REQUEST_GETALLHOTTAGLIST);
		HttpManager.getInstance().requestQueue.add(stringRequest);
	}

	/**
	 * 通用好友推荐
	 * 
	 * @param telephone
	 * @param listener
	 * @param errorListener
	 */
	public static void recommendFriend(final String page, final String size, Listener<String> listener,
			ErrorListener errorListener) {
		StringBuilder sBuilder = new StringBuilder();
		sBuilder.append(ConstanceUtil.HOST_NAME);
		sBuilder.append("/cfriend.do?func=recommendFriend");
		HttpManager.getInstance().requestQueue.cancelAll(ConstanceUtil.REQUEST_RECOMMENDFRIEND);
		StringRequest stringRequest = new StringRequest(Request.Method.POST, sBuilder.toString(), listener,
				errorListener) {
			@Override
			protected Map<String, String> getParams() throws AuthFailureError {
				// TODO Auto-generated method stub
				Map<String, String> paramsMap = new HashMap<String, String>();
				paramsMap.put("page", page);
				paramsMap.put("size", size);
				return paramsMap;
			}
		};
		stringRequest.setTag(ConstanceUtil.REQUEST_RECOMMENDFRIEND);
		HttpManager.getInstance().requestQueue.add(stringRequest);
	}

	public static void recommendFriendTag(final String tag, final String page, final String size,
			Listener<String> listener, ErrorListener errorListener) {
		StringBuilder sBuilder = new StringBuilder();
		sBuilder.append(ConstanceUtil.HOST_NAME);
		sBuilder.append("/cfriend.do?func=recommendFriendTag");
		HttpManager.getInstance().requestQueue.cancelAll(ConstanceUtil.REQUEST_RECOMMENDFRIENDTAG);
		StringRequest stringRequest = new StringRequest(Request.Method.POST, sBuilder.toString(), listener,
				errorListener) {
			@Override
			protected Map<String, String> getParams() throws AuthFailureError {
				// TODO Auto-generated method stub
				Map<String, String> paramsMap = new HashMap<String, String>();
				paramsMap.put("tag", tag);
				paramsMap.put("page", page);
				paramsMap.put("size", size);
				return paramsMap;
			}
		};
		stringRequest.setTag(ConstanceUtil.REQUEST_RECOMMENDFRIENDTAG);
		HttpManager.getInstance().requestQueue.add(stringRequest);
	}

	/**
	 * 消息列表
	 * 
	 * @param tag
	 * @param page
	 * @param size
	 * @param listener
	 * @param errorListener
	 */
	public static void getTalkList(final String telephone, Listener<String> listener, ErrorListener errorListener) {
		StringBuilder sBuilder = new StringBuilder();
		sBuilder.append(ConstanceUtil.HOST_NAME);
		sBuilder.append("/ctalk.do?func=getTalkList");
		HttpManager.getInstance().requestQueue.cancelAll(ConstanceUtil.REQUEST_GETTALKLIST);
		StringRequest stringRequest = new StringRequest(Request.Method.POST, sBuilder.toString(), listener,
				errorListener) {
			@Override
			protected Map<String, String> getParams() throws AuthFailureError {
				// TODO Auto-generated method stub
				Map<String, String> paramsMap = new HashMap<String, String>();
				paramsMap.put("telephone", telephone);
				return paramsMap;
			}
		};
		stringRequest.setTag(ConstanceUtil.REQUEST_GETTALKLIST);
		HttpManager.getInstance().requestQueue.add(stringRequest);
	}

	/**
	 * 查找好友
	 * 
	 * @param telephone
	 * @param listener
	 * @param errorListener
	 */
	public static void findFriendByTelephone(final String telephone, Listener<String> listener,
			ErrorListener errorListener) {
		StringBuilder sBuilder = new StringBuilder();
		sBuilder.append(ConstanceUtil.HOST_NAME);
		sBuilder.append("/cfriend.do?func=findFriendByTelephone");
		HttpManager.getInstance().requestQueue.cancelAll(ConstanceUtil.REQUEST_FINDFRIENDBYTELEPHONE);
		StringRequest stringRequest = new StringRequest(Request.Method.POST, sBuilder.toString(), listener,
				errorListener) {
			@Override
			protected Map<String, String> getParams() throws AuthFailureError {
				// TODO Auto-generated method stub
				Map<String, String> paramsMap = new HashMap<String, String>();
				paramsMap.put("telephone", telephone);
				return paramsMap;
			}
		};
		stringRequest.setTag(ConstanceUtil.REQUEST_FINDFRIENDBYTELEPHONE);
		HttpManager.getInstance().requestQueue.add(stringRequest);
	}

	public static void findFriendByTag(final String tag, Listener<String> listener, ErrorListener errorListener) {
		StringBuilder sBuilder = new StringBuilder();
		sBuilder.append(ConstanceUtil.HOST_NAME);
		sBuilder.append("/cfriend.do?func=findFriendByTag");
		HttpManager.getInstance().requestQueue.cancelAll(ConstanceUtil.REQUEST_FINDFRIENDBYTAG);
		StringRequest stringRequest = new StringRequest(Request.Method.POST, sBuilder.toString(), listener,
				errorListener) {
			@Override
			protected Map<String, String> getParams() throws AuthFailureError {
				// TODO Auto-generated method stub
				Map<String, String> paramsMap = new HashMap<String, String>();
				paramsMap.put("tag", tag);
				return paramsMap;
			}
		};
		stringRequest.setTag(ConstanceUtil.REQUEST_FINDFRIENDBYTAG);
		HttpManager.getInstance().requestQueue.add(stringRequest);
	}

	public static void sendTextMessage(final String sendertelephone, final String receivertelephone,
			final String msgcontent, Listener<String> listener, ErrorListener errorListener) {
		StringBuilder sBuilder = new StringBuilder();
		sBuilder.append(ConstanceUtil.HOST_NAME);
		sBuilder.append("/ctalk.do?func=sendTextMessage");
		HttpManager.getInstance().requestQueue.cancelAll(ConstanceUtil.REQUEST_SENDTEXTMSG);
		StringRequest stringRequest = new StringRequest(Request.Method.POST, sBuilder.toString(), listener,
				errorListener) {
			@Override
			protected Map<String, String> getParams() throws AuthFailureError {
				// TODO Auto-generated method stub
				Map<String, String> paramsMap = new HashMap<String, String>();
				paramsMap.put("sendertelephone", sendertelephone);
				paramsMap.put("receivertelephone", receivertelephone);
				paramsMap.put("msgcontent", msgcontent);
				paramsMap.put("msgtype", "0");
				return paramsMap;
			}
		};
		stringRequest.setTag(ConstanceUtil.REQUEST_SENDTEXTMSG);
		HttpManager.getInstance().requestQueue.add(stringRequest);
	}

	public static void getTalkMessgeList(final String mytephone, final String frtelephone, final String page,
			final String size, Listener<String> listener, ErrorListener errorListener) {
		StringBuilder sBuilder = new StringBuilder();
		sBuilder.append(ConstanceUtil.HOST_NAME);
		sBuilder.append("/ctalk.do?func=getTalkMessgeList");
		HttpManager.getInstance().requestQueue.cancelAll(ConstanceUtil.REQUEST_GETMESSAGELIST);
		StringRequest stringRequest = new StringRequest(Request.Method.POST, sBuilder.toString(), listener,
				errorListener) {
			@Override
			protected Map<String, String> getParams() throws AuthFailureError {
				// TODO Auto-generated method stub
				Map<String, String> paramsMap = new HashMap<String, String>();
				paramsMap.put("sendertelephone", mytephone);
				paramsMap.put("receivertelephone", frtelephone);
				paramsMap.put("page", page);
				paramsMap.put("size", size);
				return paramsMap;
			}
		};
		stringRequest.setTag(ConstanceUtil.REQUEST_GETMESSAGELIST);
		HttpManager.getInstance().requestQueue.add(stringRequest);
	}

	public static void setTalkList(final CTalkList cTalkList, Listener<String> listener, ErrorListener errorListener) {
		StringBuilder sBuilder = new StringBuilder();
		sBuilder.append(ConstanceUtil.HOST_NAME);
		sBuilder.append("/ctalk.do?func=setTalkList");
		HttpManager.getInstance().requestQueue.cancelAll(ConstanceUtil.REQUEST_SETMESSAGELIST);
		StringRequest stringRequest = new StringRequest(Request.Method.POST, sBuilder.toString(), listener,
				errorListener) {
			@Override
			protected Map<String, String> getParams() throws AuthFailureError {
				// TODO Auto-generated method stub
				Map<String, String> paramsMap = new HashMap<String, String>();
				paramsMap.put("mytelephone", cTalkList.getMy_telephone());
				paramsMap.put("frtelephone", cTalkList.getFriend_telephone());
				paramsMap.put("frname", cTalkList.getFriend_name());
				paramsMap.put("myname", cTalkList.getMy_name());
				paramsMap.put("fricon", cTalkList.getFriend_icon());
				paramsMap.put("myicon", cTalkList.getMy_icon());
				return paramsMap;
			}
		};
		stringRequest.setTag(ConstanceUtil.REQUEST_SETMESSAGELIST);
		HttpManager.getInstance().requestQueue.add(stringRequest);
	}

	public static void getSingleTalkList(final String sendertelephone,final String receivertelephone, Listener<String> listener, ErrorListener errorListener) {
		StringBuilder sBuilder = new StringBuilder();
		sBuilder.append(ConstanceUtil.HOST_NAME);
		sBuilder.append("/ctalk.do?func=getSingleTalkList");
		HttpManager.getInstance().requestQueue.cancelAll(ConstanceUtil.REQUEST_GETSINGLETALKLIST);
		StringRequest stringRequest = new StringRequest(Request.Method.POST, sBuilder.toString(), listener,
				errorListener) {
			@Override
			protected Map<String, String> getParams() throws AuthFailureError {
				// TODO Auto-generated method stub
				Map<String, String> paramsMap = new HashMap<String, String>();
				paramsMap.put("sendertelephone", sendertelephone);
				paramsMap.put("receivertelephone", receivertelephone);
				return paramsMap;
			}
		};
		stringRequest.setTag(ConstanceUtil.REQUEST_GETSINGLETALKLIST);
		HttpManager.getInstance().requestQueue.add(stringRequest);
	}
	

	public static void getUserInfo(final String telephone, Listener<String> listener,ErrorListener errorListener) {
		StringBuilder sBuilder = new StringBuilder();
		sBuilder.append(ConstanceUtil.HOST_NAME);
		sBuilder.append("/cuser.do?func=getUserInfo");
		HttpManager.getInstance().requestQueue.cancelAll(ConstanceUtil.REQUEST_GETUSERINFO);
		StringRequest stringRequest = new StringRequest(Request.Method.POST, sBuilder.toString(), listener,
				errorListener) {
			@Override
			protected Map<String, String> getParams() throws AuthFailureError {
				// TODO Auto-generated method stub
				Map<String, String> paramsMap = new HashMap<String, String>();
				paramsMap.put("telephone", telephone);
				return paramsMap;
			}
		};
		stringRequest.setTag(ConstanceUtil.REQUEST_GETUSERINFO);
		HttpManager.getInstance().requestQueue.add(stringRequest);
	}

	
	public static void updateUnreadMessage(final String sendertelephone,final String receivertelephone, Listener<String> listener,ErrorListener errorListener) {
		StringBuilder sBuilder = new StringBuilder();
		sBuilder.append(ConstanceUtil.HOST_NAME);
		sBuilder.append("/ctalk.do?func=updateUnreadMessage");
		HttpManager.getInstance().requestQueue.cancelAll(ConstanceUtil.REQUEST_UPDATEUNREADMESSAGE);
		StringRequest stringRequest = new StringRequest(Request.Method.POST, sBuilder.toString(), listener,
				errorListener) {
			@Override
			protected Map<String, String> getParams() throws AuthFailureError {
				// TODO Auto-generated method stub
				Map<String, String> paramsMap = new HashMap<String, String>();
				paramsMap.put("sendertelephone", sendertelephone);
				paramsMap.put("receivertelephone", receivertelephone);
				return paramsMap;
			}
		};
		stringRequest.setTag(ConstanceUtil.REQUEST_UPDATEUNREADMESSAGE);
		HttpManager.getInstance().requestQueue.add(stringRequest);
	}	
	/**
	 * 
	 * @param sendertelephone
	 * @param receivertelephone
	 * @param listener
	 * @param errorListener
	 */
	public static void deleteTalkList(final String sendertelephone,final String receivertelephone, Listener<String> listener,ErrorListener errorListener) {
		StringBuilder sBuilder = new StringBuilder();
		sBuilder.append(ConstanceUtil.HOST_NAME);
		sBuilder.append("/ctalk.do?func=deleteTalkList");
		HttpManager.getInstance().requestQueue.cancelAll(ConstanceUtil.REQUEST_UPDATEUNREADMESSAGE);
		StringRequest stringRequest = new StringRequest(Request.Method.POST, sBuilder.toString(), listener,
				errorListener) {
			@Override
			protected Map<String, String> getParams() throws AuthFailureError {
				// TODO Auto-generated method stub
				Map<String, String> paramsMap = new HashMap<String, String>();
				paramsMap.put("sendertelephone", sendertelephone);
				paramsMap.put("receivertelephone", receivertelephone);
				return paramsMap;
			}
		};
		stringRequest.setTag(ConstanceUtil.REQUEST_UPDATEUNREADMESSAGE);
		HttpManager.getInstance().requestQueue.add(stringRequest);
	}	
	/**
	 * 
	 * @param telephone
	 * @param listener
	 * @param errorListener
	 */
	public static void unRegisterDevice(final String telephone,  Listener<String> listener,
			ErrorListener errorListener) {
		StringBuilder sBuilder = new StringBuilder();
		sBuilder.append(ConstanceUtil.HOST_NAME);
		sBuilder.append("/cuser.do?func=logout");
		HttpManager.getInstance().requestQueue.cancelAll(ConstanceUtil.RQUEST_UNREGISTERDEVICE);
		StringRequest stringRequest = new StringRequest(Request.Method.POST, sBuilder.toString(), listener,
				errorListener) {
			@Override
			protected Map<String, String> getParams() throws AuthFailureError {
				// TODO Auto-generated method stub
				Map<String, String> paramsMap = new HashMap<String, String>();
				paramsMap.put("telephone", telephone);
				return paramsMap;
			}
		};
		stringRequest.setTag(ConstanceUtil.RQUEST_UNREGISTERDEVICE);
		HttpManager.getInstance().requestQueue.add(stringRequest);
	}

}